<!DOCTYPE HTML>
<html>
<head>
    <base href="__ROOT__/">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <script src="__RES__js/jquery-1.8.3.min.js" type="application/javascript"></script>
    <title>留言板</title>
</head>
<style>
    /*全局样式*/
    *{ padding:0; margin:0;}
    img{ border:0;}
    a{ text-decoration:none;}
    ul{ list-style-type:none;}

    .header{ width: 1000px; height: 50px; margin: auto; border: #9B410E solid 1px; font-size: 12px; font-family:"宋体";}

    .table{ width: 1000px; height: 200px;  border: #c09 solid 1px; margin: auto;}
    .table tr{ border: #9B410E solid 1px;}
    .table tr td{ border: #654 solid 1px;}

    .my_a{ margin-left: 600px; }
    .add_time{display: block; padding-left: 750px;}
    .tr_h{ width: 1000px; height: 30px;}
    .tr_div{ width: 1000px; height: 220px;}

    .page{ width: 1000px; height: 30px; margin: auto; text-align: center;}

    .sub_content{width: 1000px; height: 300px; margin: auto; display: none; }
    .sub_content table{ width: 1000px; height: 200px; border: #c09 solid 1px; margin: auto;}
    .sub_content table tr{ border: #9B410E solid 1px;}
    .sub_content table tr td{ border: #654 solid 1px;}

    .bottom{width: 1000px; height: 30px; margin: auto; text-align: right;}
</style>

<body>
<div class="header">
    <h1>&nbsp;&nbsp;&nbsp;&nbsp;我的留言板<a class="my_a" href="javascript:void(0)">我要留言</a></h1>
</div>
<div class="content">
    <foreach name="arr" item="value" key="key" >
<table class="table">

    <tr class="tr_h">
        <td>昵称：</td>
        <td>{$value.alias}</td>
        <td>邮箱：</td>
        <td>{$value.email}</td>
        <td>{$value.id}</td>
    </tr>
    <tr class="tr_div">
        <td  colspan="5">
            <form action="" method="post">
            <div>
                <ul>
                    <li>内容:{$value.content}</li>
                    <li class="add_time">发表时间：2015-07-07 16：33</li>
                    <foreach name="value.huifu" item="val" key="k" >
                    <li><if condition="$val['crut'] eq 1">管理员</if>{$val.alias}回复：<span>{$val.huifu}</span>&nbsp;&nbsp;&nbsp;{$val.time}&nbsp;&nbsp;&nbsp;<a class="huifu_save" href="javascript:void(0)">编辑</a>&nbsp;<a href="index.php/home/liuyan/list/delhuifu/{$val.id}">删除</a></li>
                    <li class="huifutext" style="display: none;">编辑回复：<textarea name="savehuifu" style="width: 300px; height: 40px;"></textarea><br><input type="button" class="but" saveid="{$val.id}"  value="发送" /></li>
                    </foreach>
                    <li class="crut" style="display: none;">回复：<textarea name="huifu" style="width: 300px; height: 40px;"></textarea><br><input type="submit"   value="发送" /></li>
                </ul>
            </div>
                <input name="pid" type="hidden" value="{$value.id}"/>
            </form>
        </td>
    </tr>
    <tr class="tr_h">
        <td>IP:</td>
        <td>{$value.ip}</td>
        <td  colspan="3">  <a class="hui" href="javascript:void(0)">【回复】</a>   <a class="del"  onclick="return confirm('是否删除？','是','否');" href="index.php/home/liuyan/list/delid/{$value.id}">【删除】</a></td>
    </tr>

</table>
    </foreach>
</div>
<div class="page">{$page}</div>
<div class="sub_content" id="huifu">
    <table>
        <form action="" method="post">
        <tr>
            <td>昵称：</td>
            <td colspan="2" class="sub_user"><input name="alias" type="text" value="<?php if(!empty($_SESSION['user']['alias'])) echo $_SESSION['user']['username'];?>"  /></td>
        </tr>
        <tr>
            <td>邮箱：</td>
            <td colspan="2" class="sub_email"><input name="email" type="text" value="<?php if(!empty($_SESSION['user']['email'])) echo $_SESSION['user']['email'];?>"  /></td>
        </tr>
        <tr height="200">
            <td>留言内容：</td>
            <td colspan="2" ><textarea name="content" style="width: 800px; height: 200px;"></textarea></td>
        </tr>
        <tr>
            <td colspan="2" align="center"><input type="submit"  class="sub" value="提交" /></td>
            <td width="50%" align="center"><input type="reset" class="save" value="重写" /></td>
        </tr>
        </form>
    </table>
</div>
<div class="bottom"><a href="index.php/home/index/admin">管理员登录</a></div>
<script>
    $('.my_a').click(function(){
        $(this).parent().parent().parent().find('div.sub_content').slideToggle();
        if($(this).html()=='我要留言'){
            $(this).html('收起');
        }else{
            $(this).html('我要留言');
        }
    })
    $('.hui').click(function(){
        $(this).parent().parent().prev().find('li.crut').slideToggle();
    })
    $('.huifu_save').click(function(){
        var save=$(this).prev('span').html();
        $(this).parent().next().slideToggle();
        $(this).parent().next().find('textarea').val(save);
    })
    $('.but').click(function(){
        var but_save=$(this).prev().prev().val();
        var id=$(this).attr('saveid');
        var url="index.php/home/liuyan/list";
        $.ajax({
            type:"post",
            url:url,
            data:{"id":id,
                "savehuifu":but_save
            },
            dataType:"json",
            success:function(json){
                if(json==1){
                    alert('编辑成功！');
                    var time=location.href="index.php/home/liuyan/list/p/1";
                    setTimeout("time",2000);
                }else if(json==2){
                    alert('编辑失败！');
                    var time=location.href="index.php//home/liuyan/list/p/1";
                    setTimeout("time",2000);
                }
            }
        })
    })
</script>
</body>
</html>
